package com.gupaoedu.mybatis0;


import com.gupaoedu.mybatis.my.Test;
//import org.apache.ibatis.plugin.Intercepts;

import java.sql.*;

/**
 * Created by James on 2018-04-01.
 * From 咕泡学院出品
 * 老师咨询 QQ 2904270631
 */
public class GPSimpleExecutor implements GPExecutor{
    @Override
    public <T> T query(String statement, String parameter) {
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        Test test = null;
//        try {
//            Class.forName("com.mysql.cj.jdbc.Driver");
//            connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/gp?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC", "root", "123456");
//            String sql = String.format(statement, Integer.parseInt(parameter));
//            preparedStatement = connection.prepareStatement(sql);
//            ResultSet rs = preparedStatement.executeQuery();
//            while (rs.next()) {
//                test = new Test();
//                test.setId(rs.getInt(1));
//                test.setNums(rs.getInt(2));
//                test.setName(rs.getString(3));
//            }
//        } catch (ClassNotFoundException e) {
//            e.printStackTrace();
//        } catch (SQLException e) {
//            e.printStackTrace();
//        } finally {
//            try {
//                if (null != connection) {
//                    connection.close();
//                }
//            } catch (SQLException e) {
//                e.printStackTrace();
//            }
//        }
        test = new Test(1, 1, "test-Name");
        return (T)test;
    }
}
